package com.zhx.ad.sender.kafka;

import com.zhx.ad.mysql.dto.MySqlRowData;
import com.zhx.ad.sender.ISender;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author ：zhanghaixuan
 * @date ：Created in 2019-05-14 09:13
 * @description：用途:
 * @modified By：zhanghaixuan
 * @version: 1.0
 */
@Slf4j
@Component("kafkaSender")
public class KafkaSender implements ISender {
//
//    @Value("${adconf.kakfa.topic}")
//    private String topic;
//
//    @Autowired
//    private KafkaTemplate<String, String> kafkaTemplate;
//
    @Override
    public void sender(MySqlRowData rowData) {
//        kafkaTemplate.send(topic, JSON.toJSONString(rowData));
    }
//
//    @KafkaListener(topics = {"adconf.kakfa.topic"},groupId = "ad-search")
//    public void processMysqlRowData(Consumer<?,?> consumer){
//        Optional<?> optional = Optional.ofNullable(consumer);
//
//        if(optional.isPresent()){
//            Object o = optional.get();
//
//            MySqlRowData mySqlRowData = JSON.parseObject(o.toString(), MySqlRowData.class);
//            log.info("kafka process mySqlRowData:{}",JSON.toJSONString(mySqlRowData));
//        }
//
//    }
}
